home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscMatrix.h < prev    next >
Encoding:
Text File  |  1995-07-20  |  4.9 KB  |  144 lines

  1. //
  2. //    MiscMatrix.h -- a class to implement variable-sized matrices
  3. //        Written by Mike Ferris Copyright (c) 1994 by Mike Ferris.
  4. //        Modified from original MOKit "MOMatrix" class by Don Yacktman.
  5. //                Version 1.0.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. // MiscMatrix is a subclass of Matrix that allows independantly sizable
  16. // rows and columns.  Each row can have a different height and each column
  17. // can have a different width.
  18.  
  19. /*
  20.    Bugs: In the private methods for altering row/column locations when you
  21.          insert a row/column before the last position, the last position
  22.      would not get properly incremented.
  23.  
  24.          If you have 0 rows and 0 cols in the matrix, when you go to insert a
  25.          row it'll insert a column for you, similarly if you insert a col it'll
  26.          insert a row, MiscMatrix wasn't taking that into account.
  27.      
  28.      Modified the _loopHit to work a little better by calling
  29.      getRow:andCol:forPoint:wantsGuess:TRUE, which will insure that
  30.      you get the proper number of selected cells if you drag out of
  31.      the window
  32.      
  33.      I think it was SQ, but SQ postulated that addRow is really a front
  34.      for insertRowAt: and to prove his point he left in some code that
  35.      would log a message if it didn't work the way he posulated.  It
  36.      does work the way SQ postulated (at least from my experience) but it
  37.      is still possible for his message to print.  The error could be
  38.      printed if these steps happen:  init a matrix via initFrame:, now
  39.      the matrix will have 0 cells, but its numRows == numCols == 1.  If
  40.      you then go and call addRow, its numRows == numCols == 1 in the
  41.      begining and end, which logs an error.  I just took out the
  42.      methods for addRow/addCol as they weren't really doing anything.
  43. */
  44.  
  45. /* 
  46.     Posible Bug: (Carl E. Lindberg <lindberg@CS.COLGATE.EDU>)
  47.     Playing with my very simple example, (just using Buttons as
  48.     the cells), I was very occasionally able to get a one-pixel
  49.     error (one pixel of the last row/column buttons was clipped),
  50.     but otherwise I think it worked exactly as the docs to Matrix
  51.     say it should.  Usually, it worked just fine, and calls to
  52.     -setAutosizeCells: would line that one pixel back up.
  53.     
  54.     If this one-pixel thing may be a problem, use the 
  55.     #ifdef FUDGE sections in the two methods.  Basically, they are
  56.     just making the resizing calculations size to one pixel smaller.
  57.     This means that the occasional error will now be perfectly on
  58.     the edge, but usually you have an extra pixel's space around
  59.     two edges of the MiscMatrix.  Since the regular Matrix often
  60.     seems to have more than one pixel, I doubt this is a problem.
  61. */
  62.  
  63. /* Note: I (Georg Tuparev <Tuparev@EMBL-Heidelberg.de> am writing 
  64.     completely new version for the MiscKit 2.x. Please send me suggestions
  65.     and wishes. I'm going to combine the functionality of MiscMatrix and
  66.     MiscSelectionMatrix as well as The NiftyMatrix (NeXT Examples) and build 
  67.     entire hierarchy of classes, including simple one column browser, 
  68.     IndentBrowser (similar to the new IB class view) and different palettes.
  69. */
  70.  
  71. #import <appkit/appkit.h>
  72.  
  73. typedef struct _MiscColumnSize_ {
  74.     NXCoord        x;
  75.     NXCoord        width;
  76. }  MiscColumnSize;
  77. #define MISC_COLUMNSIZE_DESC        "{ff}"
  78.  
  79. typedef struct _MiscRowSize_ {
  80.     NXCoord        y;
  81.     NXCoord        height;
  82. }  MiscRowSize;
  83. #define MISC_ROWSIZE_DESC        "{ff}"
  84.  
  85. @interface MiscMatrix : Matrix
  86. {
  87.     Storage *columnSizes, *rowSizes;
  88.     
  89. }
  90.  
  91. + initialize;
  92.  
  93. - initFrame:(const NXRect *)frm mode:(int)aMode prototype:cellId 
  94.             numRows:(int)rowsHigh numCols:(int)colsWide;
  95. - initFrame:(const NXRect *)frm mode:(int)aMode cellClass:factoryId 
  96.             numRows:(int)rowsHigh numCols:(int)colsWide;
  97.  
  98. - copyFromZone:(NXZone *)zone;
  99.  
  100. - free;
  101.  
  102. - setWidth:(NXCoord)newWidth ofCol:(int)col;
  103. - setHeight:(NXCoord)newHeight ofRow:(int)row;
  104. - (float)widthOfCol:(int)aCol;
  105. - (float)heightOfRow:(int)aRow;
  106.  
  107. - (float)totalWidthPerRow;
  108.  
  109. - setCellSize:(const NXSize *)aSize;
  110. - sizeToCells;
  111. - sizeToFit;
  112. - sizeRowsToFitCells;
  113. - sizeTo:(NXCoord)width :(NXCoord)height;
  114. - setAutosizeCells:(BOOL)flag;
  115.  
  116. - renewRows:(int)newRows cols:(int)newCols;
  117.  
  118. - insertColAt:(int)col;
  119. - insertRowAt:(int)row;
  120. - removeColAt:(int)col andFree:(BOOL)flag;
  121. - removeRowAt:(int)row andFree:(BOOL)flag;
  122.  
  123. - drawSelf:(const NXRect *)rects :(int)rectCount;
  124.  
  125. - getCellFrame:(NXRect *)theRect at:(int)row :(int)col;
  126. - getRow:(int *)row andCol:(int *)col forPoint:(const NXPoint *)aPoint;
  127. - getRow:(int *)row andCol:(int *)col forPoint:(const NXPoint *)aPoint
  128.   wantsGuess:(BOOL)shouldGuess;
  129.  
  130. - setIntercell:(const NXSize *)aSize;
  131.  
  132. - (int)numCols;
  133. - (int)numRows;
  134.  
  135. - write:(NXTypedStream *)typedStream;
  136. - read:(NXTypedStream *)typedStream;
  137.  
  138. @end
  139.  
  140. @interface Storage(MiscLastElementCategory)
  141.     
  142. - (void *)lastElement;
  143.  
  144. @end